import React, { memo, useState, useEffect, useRef, useCallback } from "react";
import { useDispatch, useSelector, shallowEqual } from "react-redux";
import { Empty } from "antd";
import { UserArticleWrapper } from "./style";
import { getFavArticleList } from "@/service/article";
import { getArticleCategory } from "@/service/index";
import { getUserArticle } from "@/service/user";
import MyArticle from "./myArticle";
export default memo(function UserArticle() {

  const [Article, setArticle] = useState([]);

  let { userDetail } = useSelector(
    (state) => ({
      userDetail: state.getIn(["public", "userDetail"]),
    }),
    shallowEqual
  );

  useEffect(() => {
    getArticle()
  }, []);

  const getArticle = async () => {
    let obj={
      tagsLike:userDetail.id+'yipianyue'
    }
    const res = await getUserArticle(obj);
    setArticle(res.data.result)
  };

  return (
    <UserArticleWrapper>
      {Article.length > 0 ? (
        <MyArticle articles={Article}></MyArticle>
      ) : (
        <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
      )}
    </UserArticleWrapper>
  );
});
